﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8" />
    <title>通用的实体编辑页面</title>
    <link href="../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script src="../../WF/Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../WF/Scripts/QueryString.js" type="text/javascript"></script>
    <link href="../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <!-- 引用通用的js文件. -->
    <script type="text/javascript" src="../../WF/Scripts/config.js"></script>
    <script type="text/javascript" src="../../WF/Comm/Gener.js"></script>
    <script type="text/javascript" language="javascript">
        //页面启动函数.
        $(function () {

            $("#Msg").html("正在加载,请稍后......");
             

            //创建实体.
            var no = GetQueryString("No");

            var en = new Entity("BP.Demo.BPFramework.Student");
            if (no != null) {
                en.SetPKVal(no);
                en.RetrieveFromDBSources();
            }

            //增加的节点值 
            GenerBindEntities("DDL_FK_BanJi", "BP.Demo.BPFramework.BanJis");
            //绑定枚举.
            GenerBindEnumKey("DDL_XB", "XB");
            //政治面貌.
            GenerBindEnumKey("DDLPara_ZZMM", "ZZMM");

            //调用公共类库的方法:执行批量主表赋值
            GenerFullAllCtrlsVal(en);

            //设置信息为空.
            $("#Msg").html("");
        });

        function Save() {

            //创建实体.
            var no = GetQueryString("No");
            var en = new Entity("BP.Demo.BPFramework.Student");

            if (no == null) {

                en.CopyForm();

                if (en.IsExits() == true) {
                    alert("编号:" + en.No + "已经存在.");
                    return;
                }
                en.Insert();
                window.location.href = "Student.htm?No=" + en.No;
            }

            if (no != null) {

                en.SetPKVal(no);
                en.RetrieveFromDBSources();
                en.CopyForm();
                en.Save();
                window.location.href = window.location.href;
            }
        }

        function New() {
            window.location.href = 'Student.htm';
        }

        function ToList() {
            window.location.href = 'StudentList.htm';
        }

    </script>
</head>
<body>
    <table style="width: 99%;">
        <caption>
            学生信息-编辑</caption>
        <tr>
            <th colspan="4">
                基本字段(类的属性与字段名一致): 控件的命名规则是， DDL_+字段名, TB_+字段名, CB_+字段名.
            </th>
        </tr>
        <tr>
            <td>
                学号
            </td>
            <td>
                <input type="text" value="" id="TB_No" name="TB_No" />
            </td>
            <td>
                名称
            </td>
            <td>
                <input type="text" value="" id="TB_Name" name="TB_Name" />
            </td>
        </tr>
        <tr>
            <td>
                班级 (外键类型)
            </td>
            <td>
                <select id="DDL_FK_BanJi" name="DDL_FK_BanJi" />
            </td>
            <td>
                性别（枚举类型）
            </td>
            <td>
                <select id="DDL_XB" name="DDL_XB" />
            </td>
        </tr>
        <tr>
            <td>
                Email
            </td>
            <td colspan="3">
                <input type="text" value="" style="width: 100%;" id="TB_Email" name="TB_Email" />
            </td>
        </tr>
        <tr>
            <td>
                checkbok类型
            </td>
            <td colspan="3">
                <label>
                    <input type="checkbox" value="" id="CB_IsTeKunSheng" name="CB_IsTeKunSheng" />是否特困生</label>
            </td>
        </tr>
        <!-- 参数字段  -->
        <tr>
            <th colspan="4">
                参数字段(类里面有一个AtPara字段): 控件的命名规则是， DDLPara_+字段名, TBPara_+字段名, CBPara_+字段名.
            </th>
        </tr>
        <tr>
            <td>
                String类型参数
            </td>
            <td>
                <input type="text" value="" id="TBPara_MyAddr" name="TBPara_MyAddr" />
            </td>
            <td>
                下拉框类型参数
            </td>
            <td>
                <select id="DDLPara_ZZMM" name="DDLPara_ZZMM" />
            </td>
        </tr>
        <tr>
            <td>
            </td>
            <td colspan="3">
                <label>
                    <input type="checkbox" value="" id="CBPara_Boolen" name="CBPara_Boolen" />布尔类型参数</label>
            </td>
        </tr>
    </table>
    <input type="button" value="返回列表" onclick="ToList();" id="Btn_ToList" name="Btn_ToList" />
    <input type="button" value="新建" onclick="New();" id="Button1" name="Btn_New" />
    <input type="button" value="保存" onclick="Save();" id="Btn_Save" name="Btn_Save" />
    <div id="Msg">
    </div>
</body>
</html>
